import allure
from selenium.webdriver.common.by import By

from BasePage.BasePage import BasePage
from Page.MainPage import Main


class Login(BasePage):
    __name = (By.CSS_SELECTOR, '[name="username"]')
    __password = (By.CSS_SELECTOR, '[name="password"]')
    __click_login = (By.XPATH, "//*[text()='登录']")

    @allure.step('登录')
    def login_page(self, name='manage', password='manage123'):
        # 登录页面
        self.url('https://litemall.hogwarts.ceshiren.com/#/login')
        # 账号
        self.find_ele(self.__name).clear()
        self.find_ele(self.__name).send_keys(name)
        # 密码
        self.find_ele(self.__password).clear()
        self.find_ele(self.__password).send_keys(password)
        # 点击登录
        self.find_ele(self.__click_login).click()
        return Main(self.driver)
